#ifndef PAGEMANAGER_H
#define PAGEMANAGER_H

#include "ad.h"
#include "mainwindow.h"
#include <QObject>
#include <QStackedWidget>
#include <QTimer>

class PageManager : public QObject {
  Q_OBJECT

public:
  explicit PageManager(MainWindow *mainWindow,
                       QObject *parent = nullptr); // 修改构造函数
  ~PageManager();

  void init();
  void showMainPage();
  void showAdPage();
  QTimer *getQTimer();
  QTimer *returnTimer;
  int returnDelay = 8000; // 5秒后返回广告页

public slots:
  void onRfidCardDetected(QString cardNumber);
  void open_ReturnTimer();

private:
  QStackedWidget *stackedWidget;
  MainWindow *mainWindow; // 使用外部传入的实例
  ad *adPage;

  QString card_number;
};

#endif // PAGEMANAGER_H
